package com.cnswhy.cloud.server.common.entity.enumeration;

import com.cnswhy.cloud.common.core.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 
 * </p>
 *
 * @author cnswhy
 * @date 2020-10-14
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "WalletType", description = "钱包类型 #WalletType{BALANCE:余额;NO_CARD:快捷收益;")
public enum WalletType implements BaseEnum {

    /**
     * BALANCE="默认账户"
     */
    BALANCE("默认账户"),
    /**
     * NO_CARD="快捷收益"
     */
    NO_CARD("快捷收益"),
    REWORD("奖励收益"),
    IOTCL("充电线收益"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 跟就当前枚举的name匹配
     */
    public static WalletType match(String val, WalletType def) {
        return Stream.of(values()).parallel().filter((item) -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static WalletType get(String val) {
        return match(val, null);
    }

    public boolean eq(WalletType val) {
        return val == null ? false : eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "BALANCE,NO_CARD,REWORD", example = "BALANCE")
    public String getCode() {
        return this.name();
    }

}
